package user

import (
	"context"

	"gf-demo/api/user/v1"
	"gf-demo/internal/dao"
	"gf-demo/internal/model/do"
)

func (c *ControllerV1) CreateUser(ctx context.Context, req *v1.CreateUserReq) (res *v1.CreateUserRes, err error) {
	insertId, err := dao.User.Ctx(ctx).Data(do.User{
			Name: req.Name,
			Status: v1.StatusOK,
			Age: req.Age,
		}).InsertAndGetId()

	if err != nil {
		return nil, err
	}
	
	res = &v1.CreateUserRes{
		Id: insertId,
	}
	return
}
